import axios from '@/plugins/axios/index'
import { ref } from 'vue'
import { Store } from '@/utils/storage'

const store = new Store()

export default () => {
   const form = ref<{ username: string; password: string }>({
      username: 'xiaosong',
      password: 'xiaosong123'
   })
   const login = async () => {
      const res = await axios.request<{ token: string }>({
         url: '/login',
         method: 'post'
      })

      store.setStorage('token', { token: res.data.token })
   }

   return { login, form }
}
